package hsrt.com.dynamiccomponent_android.dynamic_component;

import com.chad.library.adapter.base.entity.AbstractExpandableItem;

import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Map;

public class DataElement<T> extends AbstractExpandableItem<DataElement<T>> implements DataElementInterface<T> {

    private WeakReference<DataElementInterface> previous;
    private DataElementInterface next;
    private int section;
    private boolean isEdit;
    private String childObjectName;
    private String childObjectFlag;
    private T dataModel;
    private boolean isFirstInSection;
    ///当前是否是订阅者
    private boolean isSubscriber;
    ///订阅者,当前对象和其他对象绑定的时候,当前对象修改值以后通知给subscriber对象.
    private List<DataElementInterface> subscribers;

    @Override
    public WeakReference<DataElementInterface> getPrevious() {
        return previous;
    }

    @Override
    public void setPrevious(WeakReference<DataElementInterface> previous) {
        this.previous = previous;
    }

    @Override
    public DataElementInterface getNext() {
        return next;
    }

    @Override
    public void setNext(DataElementInterface next) {
        this.next = next;
    }

    @Override
    public int getSection() {
        return section;
    }

    @Override
    public void setSection(int section) {
        this.section = section;
    }

    @Override
    public String getChildObjectName() {
        return childObjectName;
    }

    @Override
    public void setChildObjectName(String childObjectName) {
        this.childObjectName = childObjectName;
    }

    @Override
    public String getChildObjectFlag() {
        return childObjectFlag;
    }

    @Override
    public void setChildObjectFlag(String childObjectFlag) {
        this.childObjectFlag = childObjectFlag;
    }

    @Override
    public boolean isEdit() {
        return isEdit;
    }

    @Override
    public void setEdit(boolean edit) {
        this.isEdit = edit;
    }

    @Override
    public T dataModel() {
        return dataModel;
    }

    @Override
    public void setDataModel(T dataModel) {
        this.dataModel = dataModel;
    }

    @Override
    public boolean isSubscriber() {
        return isSubscriber;
    }

    @Override
    public void setIsSubscriber(boolean subscriber) {
        this.isSubscriber = subscriber;
    }

    @Override
    public List<DataElementInterface> getSubscribers() {
        return subscribers;
    }

    @Override
    public void setSubscribers(List<DataElementInterface> subscribers) {
        this.subscribers = subscribers;
    }

    public boolean isFirstInSection() {
        return isFirstInSection;
    }

    public void setFirstInSection(boolean firstInSection) {
        isFirstInSection = firstInSection;
    }

    @Override
    public Map<String, Object> getSubmitData() {
        return null;
    }


    @Override
    public int getItemType() {
        return 0;
    }

    @Override
    public String validationWithData(Map<String, Object> preUploadData) {
        return null;
    }

    @Override
    public int getLevel() {
        return isFirstInSection ? 0 : 1;
    }
}
